EFINE VARIABLE voutput AS CHARACTER
define variable vdate as date  .
define variable vdb like ad_name_control initial "".

for first ad_mstr no-lock where ad_addr = "~~reports".
end.
if avail ad_mstr then do:
    assign vdb =  ad_name_control .
end.

find code_mstr NO-LOCK WHERE code_fldname = "exptab2csv" and code_value = "output" no-error.
if avail code_mstr then do:
    assign voutput = code_cmmt.
end.


assign vdate = today - 1.


output to value(voutput + "hwot_det.csv").
FOR EACH hwot_det NO-LOCK WHERE hwot_date = vdate  :


    put vdb ",".
 
if hwot_date  = ? then do:
    put ",".
end.
else  do:
    put string(year(hwot_date ),"9999") + "-" + string(month(hwot_date ),"99") + "-" + string(day(hwot_date ),"99") format "x(10)" ",".
end.
put   
"""" hwot_team         """," 
     hwot_ln   format "->>>>>>9"   "," 
"""" hwot_phase        """," 
"""" hwot_status       """," 
     hwot_emp_std     format "->>>>>>9.9<<"  "," 
     hwot_emp_act     format "->>>>>>9.9<<"  "," 
     hwot_person_std  format "->>>>>>9.9<<"  ","
     hwot_person_act  format "->>>>>>9.9<<"  ","
"""" hwot_nextday      """," 
     hwot_mshift     format "->>>>>>9" ","
"""" hwot_prog       format "x(12)"    """," 
"""" hwot_user1        """," 
"""" hwot_user2        """," 
"""" hwot__chr01       """," 
"""" hwot__chr02       """," 
"""" hwot__chr03       """," 
"""" hwot__chr04       """," 
"""" hwot__chr05       """," .
if hwot__dte01  = ? then do:
    put ",".
end.
else  do:
    put string(year(hwot__dte01 ),"9999") + "-" + string(month(hwot__dte01 ),"99") + "-" + string(day(hwot__dte01),"99") format "x(10)" ",".
end.
if hwot__dte02  = ? then do:
    put ",".
end.
else  do:
    put string(year(hwot__dte02 ),"9999") + "-" + string(month(hwot__dte02 ),"99") + "-" + string(day(hwot__dte02),"99") format "x(10)" ",".
end.
put
     hwot__dec01    format "->>>>>>>>9.9<<<<<<" ","
     hwot__dec02    format "->>>>>>>>9.9<<<<<<" ","
     hwot__dec03    format "->>>>>>>>9.9<<<<<<" ","
     hwot__dec04    format "->>>>>>>>9.9<<<<<<" ","
     hwot__dec05    format "->>>>>>>>9.9<<<<<<" ","
     hwot__int01    format "->>>>>>>>9" "," 
     hwot__int02    format "->>>>>>>>9" "," 
     hwot__int03    format "->>>>>>>>9" "," 
     hwot__int04    format "->>>>>>>>9" "," 
     hwot__int05    format "->>>>>>>>9" "," 
"""" hwot__log01       """," 
"""" hwot__log02       """" 
.
put skip.

END.

output to output to value(voutput + "hwom_det.csv").
FOR EACH hwom_det NO-LOCK WHERE hwom_date = vdate  :

put vdb ",".
if hwom_date  = ? then do:
    put ",".
end.
else  do:
    put string(year(hwom_date ),"9999") + "-" + string(month(hwom_date ),"99") + "-" + string(day(hwom_date ),"99") format "x(10)" ",".
end.
put   
"""" hwom_team         """," 
"""" hwom_phase        """," 
     hwom_ln   format "->>>>>>9"   "," 
     hwom_sn   format "->>>>>>9"   "," 
"""" hwom_lot   """," 
"""" hwom_nbr          """," 
"""" hwom_part         """," 
     hwom_op   format "->>>>>>9"   "," 
"""" hwom_wkctr        """," 
"""" hwom_op_desc      """," 
"""" hwom_dept         """," 
     hwom_emp_std     format "->>>>>>9.9<<"  "," 
     hwom_emp_act     format "->>>>>>9.9<<"  "," 
     hwom_person_std  format "->>>>>>9.9<<"  ","
     hwom_person_act  format "->>>>>>9.9<<"  ","
     hwom_setup_std   format "->>>>>>9.9<<"  ","
     hwom_setup_act   format "->>>>>>9.9<<"  ","
     hwom_run_std     format "->>>>>>9.9<<"  "," 
     hwom_run_act     format "->>>>>>9.9<<"  "," 
     hwom_move_std    format "->>>>>>9.9<<"  ","
     hwom_move_act    format "->>>>>>9.9<<"  ","
     hwom_qty_std     format "->>>>>>9.9<<<" ","
     hwom_qty_ord     format "->>>>>>9.9<<<" ","
     hwom_qty_inpt    format "->>>>>>9.9<<<" "," 
     hwom_qty_wip     format "->>>>>>9.9<<<" "," 
     hwom_qty_comp    format "->>>>>>9.9<<<" ","
     hwom_qty_rjct    format "->>>>>>9.9<<<" ","
     hwom_qty_rwrk    format "->>>>>>9.9<<<" ","
"""" hwom_status       """," 
"""" hwom_st_desc      """," 
"""" hwom_vend         """," 
"""" hwom_po_nbr       """," 
"""" hwom_po_line      """," 
     hwom_yield_pct   format "->>>>>>9.9<<<" ","
     hwom_bdn_std     format "->>>>>>9.9<<<" ","
     hwom_bdn_act     format "->>>>>>9.9<<<" ","
     hwom_lbr_std     format "->>>>>>9.9<<<" ","
     hwom_lbr_act     format "->>>>>>9.9<<<" ","
     hwom_sub_std     format "->>>>>>9.9<<<" ","
     hwom_sub_act     format "->>>>>>9.9<<<" ","
     hwom_setup_rte   format "->>>>>>9.9<<<<" ","
     hwom_lbr_rate    format "->>>>>>9.9<<<<" ","
     hwom_bdn_pct     format "->>>>>>9.9<<<" "," 
"""" hwom_PrLine       """," 
"""" hwom_nextday      """," 
     hwom_mshift     format "->>>>>>9" ","
     hwom_bdn_rate   format "->>>>>>9.9<<<<" ","
"""" hwom_desc         """," 
"""" hwom_milestone    """," 
"""" hwom_mod_userid   """," .
if hwom_mod_date  = ? then do:
    put ",".
end.
else  do:
    put string(year(hwom_mod_date ),"9999") + "-" + string(month(hwom_mod_date ),"99") + "-" + string(day(hwom_mod_date ),"99") format "x(10)" ",".
end.
put 
"""" hwom_chk_userid   """," .
if hwom_chk_date  = ? then do:
    put ",".
end.
else  do:
    put string(year(hwom_chk_date ),"9999") + "-" + string(month(hwom_chk_date ),"99") + "-" + string(day(hwom_chk_date ),"99") format "x(10)" ",".
end.
put
"""" hwom_aud_userid   """," .
if hwom_aud_date  = ? then do:
    put ",".
end.
else  do:
    put string(year(hwom_aud_date ),"9999") + "-" + string(month(hwom_aud_date ),"99") + "-" + string(day(hwom_aud_date ),"99") format "x(10)" ",".
end.
put
"""" hwom_prog   format "x(12)" """," 
"""" hwom_user1        """," 
"""" hwom_user2        """," 
"""" hwom__chr01       """," 
"""" hwom__chr02       """," 
"""" hwom__chr03       """," 
"""" hwom__chr04       """," 
"""" hwom__chr05       """," .
if hwom__dte01  = ? then do:
    put ",".
end.
else  do:
    put string(year(hwom__dte01 ),"9999") + "-" + string(month(hwom__dte01 ),"99") + "-" + string(day(hwom__dte01),"99") format "x(10)" ",".
end.
if hwom__dte02  = ? then do:
    put ",".
end.
else  do:
    put string(year(hwom__dte02 ),"9999") + "-" + string(month(hwom__dte02 ),"99") + "-" + string(day(hwom__dte02),"99") format "x(10)" ",".
end.
put
     hwom__dec01    format "->>>>>>>>9.9<<<<<<" ","
     hwom__dec02    format "->>>>>>>>9.9<<<<<<" ","
     hwom__dec03    format "->>>>>>>>9.9<<<<<<" ","
     hwom__dec04    format "->>>>>>>>9.9<<<<<<" ","
     hwom__dec05    format "->>>>>>>>9.9<<<<<<" ","
     hwom__int01    format "->>>>>>>>9" "," 
     hwom__int02    format "->>>>>>>>9" "," 
     hwom__int03    format "->>>>>>>>9" "," 
     hwom__int04    format "->>>>>>>>9" "," 
     hwom__int05    format "->>>>>>>>9" "," 
"""" hwom__log01       """," 
"""" hwom__log02       """" 
.
put skip.

END.
